package org.elephantt.webby;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class SimpleResponder implements Responder {
  public void respond(HttpServletRequest request, HttpServletResponse response, Object controllerReturnValue) throws IOException {
    SimpleResponse or = (SimpleResponse) controllerReturnValue;
    if (or.getContentType() != null) {
      response.setContentType(or.getContentType());
      String value = or.getObject().toString();
      response.setContentLength(value.length());
      response.getOutputStream().print(value);
    }
  }
}